﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using EPiServer.Core;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PageTypeBuilder;
using TemplateFoundation.Configuration;
using TemplateFoundation.CustomProperties;
using TemplateFoundation.Tests.Environment;
using TemplateFoundation.Tests.PageTypes;

namespace TemplateFoundation.Tests.UnitTests.Tags
{
    [TestClass]
    public class PropertyTagsTest
    {
        [TestInitialize]
        public void Initialize()
        {
            if (PageReference.IsNullOrEmpty(Settings.Instance.TagsContainer))
            {
                PageStructure.CreateTagsContainer("Tags", PageReference.RootPage);
            }

            Settings.Instance.TagPageTypeId = PageTypeResolver.Instance.GetPageTypeID(typeof(TagsContainerPage)).Value;
        }

        [TestMethod]
        public void TestParseSingleTagString()
        {
            var tag = PropertyTags.Parse("test");

            Assert.IsTrue(tag.Tags.Count==1, "Expected a single tag");

            Assert.IsTrue(tag.Tags.First().Name=="test", "Expected a tag with name 'test'");
        }
    }
}
